#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    int findMinDifference(vector<string>& timePoints) {
        int MAX = 24 * 60;
        if (timePoints.size() > MAX) return 0;
        vector<int>minutes(timePoints.size());
        for (int i = 0; i < timePoints.size(); ++i) {
            minutes[i] = atoi(timePoints[i].substr(0, 2).c_str()) * 60 + atoi(timePoints[i].substr(3, 2).c_str());
        }
        sort(minutes.begin(), minutes.end(), less<int>());
        int res = minutes.front() + MAX - minutes.back();
        for (int i = 0; i < minutes.size()-1; ++i) {
            int tmp = minutes[i + 1] - minutes[i];
            if (res > tmp)
                res = tmp;
        }
        return res;
    }
};